using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Design.ValidatorNodes;
using EntLibContrib.Validation.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;

namespace EntLibContrib.Validation.Design.Nodes
{
    /// <summary>
    /// Respresents the designtime configuration node for an <see cref="CollectionCountValidatorData"/>.
    /// </summary>
    public class CollectionCountValidatorNode : RangeValidatorNodeBase<int>
    {
        /// <summary>
        /// Creates an instance of <see cref="CollectionCountValidatorNode"/> based on default values.
        /// </summary>
        public CollectionCountValidatorNode()
            : this(new CollectionCountValidatorData(Resources.CollectionCountValidatorNodeName))
        {
        }


        /// <summary>
        /// Creates an instance of <see cref="CollectionCountValidatorData"/> based on runtime configuration data.
        /// </summary>
        /// <param name="validatorData">The corresponding runtime configuration data.</param>
        public CollectionCountValidatorNode(CollectionCountValidatorData validatorData)
            : base(validatorData)
        {
        }

        /// <summary>
        /// Returns the runtime configuration data that is represented by this node.
        /// </summary>
        /// <returns>An instance of <see cref="CollectionCountValidatorData"/> that can be persisted to a configuration file.</returns>
        public override ValidatorData CreateValidatorData()
        {
            CollectionCountValidatorData validatorData = new CollectionCountValidatorData(Name);
            SetValueValidatorBaseProperties(validatorData);
            SetRangeValidatorBaseProperties(validatorData);

            return validatorData;
        }
    }
}
